package payment

import (
	"errors"
)

// ProcessOrder 处理支付订单
func ProcessOrder(factory PaymentFactory, amount int64) error {

	// 创建支付渠道
	payment := factory.Create()
	// 风控检查
	if !payment.RiskCheck(amount) {
		return errors.New("risk check failed")
	}
	// 支付
	_, err := payment.Pay(amount)
	return err
}
